#ifndef ROOM_H
#define ROOM_H

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <time.h>
#include <Windows.h>
#include <list>
#include "cWall.h"
#include "cDoor.h"
#include "DungeonParser.h"
#include "cGraphics.h"
#include "Assets.h"

using namespace std;

//These are constants which will be used
//to help with defining the space of the
//game world
#define ROOM_WIDTH			11
#define ROOM_HEIGHT			11

#define WALL_SIZEX			64
#define WALL_SIZEY			64

#define NUM_OF_ROOMS		4
#define NUM_OF_INTERACTS	4

#define MAX_DOORS			4
#define MAX_WALLS			36


//Constant for room type
#define STANDARD_ROOM		0			//Room fill with static objects
#define HAZARD_ROOM			1			//The player must make it to the switch before they set off a trap
#define ENEMY_ROOM			2			//The player must defeat all enemies before they can move on
#define ITEM_ROOM			3			//Grants the player the opportunity to find equipment
#define FOUNTAIN_ROOM		4			//Allows the player to heal at the fountain
#define BOSS_ROOM			5			//Initiates a boss fight when the player enters

//Creates a data structure which holds the information
//pertaining to a tile
struct Tile
{
	//Will be used to confirm tile type
	char type;

	//Will be used to hold the position of the tile on the x-axis
	int posX;

	//Will be used to hold the position of the tile on the y-axis
	int posY;

	//Will be used to test whether a player can move to that position or
	//not.
	bool bIsSpaceFree;
};

//Stores information on the Player Spawner which is in a room
struct sPlayerStart
{
	//Condition for checking to see if the player has spawned
	bool		bHasSpawned;

	//Controls the position in which will be past to the player
	Vector3D	position;
};

//Stores information on the enemy spawner system which is in the room
struct sEnemySpawner
{
	//Condition for check to see if the enemy has spawned
	bool		bHasSpawned;

	//Capacity for the amount of enemies which spawn from
	//this spawner location
	int			spawnerCapacity;

	//Controls the position in which will be past to the enemy
	Vector3D	position;
};

//Stores information on the triggers which are in the room
struct sTrigger
{
	//Condition to check if the trigger was created
	bool		bIsLive;

	//Condition to check and see if the trigger is touched
	bool		bIsTouched;

	//Controls the position of the trigger
	Vector3D	position;

	//Controls the radius of the trigger
	Vector3D	radius;
};

//Stores information on the objects which are in the room
struct sObject
{
	//Controls the position of the object
	Vector3D	position;

	//Condition to see if the object has collision detection
	bool		bIsCollidable;
};

class Room
{
	public:
		//Creates an instance of the room for the level
		Room(int roomId = -1, int roomType = -1);

		//Destroys an instance of the room from the dungeon
		~Room();

		//This function will gather information about
		//the tiles and static objects within the room
		bool initDesignRoom();

		//This function will be used to initialize all information
		//into the for creation and updating purposes
		bool initRoom();

		//This function will display the information to the
		//screen.
		void	renderRoom();

		//Retrieves the room id for the use of finding it within
		//a level
		int		getRoomId() { return m_roomId; }

		int		getType() { return m_roomType; }
		//Change the room type for the 
		void	setRoomType(int roomType);

		//Retreives the number of tiles in the room
		int		getNumOfTiles() { return m_numberOfTiles; }

		//Retreives the number of objects in the room
		int		getNumOfObjects() { return m_numberOfObjects; }

		std::list<cDoor> getDoorList() { return doorList; }
		std::list<cWall> getWallList() { return wallList; }

		bool	getEnemySpawner() { return m_bHasEnemySpawner; }
		bool	getPlayerStart() { return m_bHasPlayerStart; }
		bool	getFountain() { return m_bHasFountain; }
		bool	getFluxGenerator() { return m_bHasFluxGenerator; }

		void	setEnemySpawner(bool bHasES) { m_bHasEnemySpawner = bHasES; }
		void	setPlayerStart(bool bHasPS) { m_bHasPlayerStart = bHasPS; }
		void	setFountain(bool bHasF) { m_bHasFountain = bHasF; }
		void	setFluxGenerator(bool bHasFG) { m_bHasFluxGenerator = bHasFG; }

	private:
		//Provide Room File Associated with the Number entered
		void	openFile(int roomNumber = 0, bool bIsDesign = false);

		//This will be used to identify the room in the level
		//will as be used to decide the position in the level.
		unsigned int		m_roomId;

		//This will be used to identify the type of room in the
		//level
		unsigned int		m_roomType;
		
		//Holds the information regarding the number of tiles
		//currently in the room
		int					m_numberOfTiles;

		//Holds the information regarding the number of objects
		//currently in the room
		unsigned int		m_numberOfObjects;

		//To be used in order to loop through the array
		int row, col;

		//List which holds the information for the door
		std::list<cDoor>	doorList;

		//List which holds the information for the wall
		std::list<cWall>	wallList;

		//Flags for testing to see if the items are in the room
		bool	m_bHasEnemySpawner;
		bool	m_bHasStaticObjects;
		bool	m_bHasPlayerStart;
		bool	m_bHasFountain;
		bool	m_bHasFluxGenerator;
		bool	m_bHasBoss;

		//Holds the information for the Input Stream file
		ifstream currentDesignFile;

		//Holds the information regarding the tile structure
		//data
		Tile	m_tiles[ROOM_WIDTH][ROOM_HEIGHT];
};
#endif